package YOONA;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;
//@WebServlet("/a")
@WebServlet(name = "a", urlPatterns ={"/hello1","/hello2","/hello3"},loadOnStartup = 1,
        initParams = {@WebInitParam(name="username",value = "yoona"),
                      @WebInitParam(name = "password",value = "123456")
        })
public class a extends HttpServlet {


    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Date date = new Date();
        req.setAttribute("date",date);
        Object date1 = req.getAttribute("date");
        resp.setContentType("text/html");
        PrintWriter writer = resp.getWriter();
        writer.print(date1);
        req.getRequestDispatcher("/index.html").forward(req,resp);

//        RequestDispatcher requestDispatcher = req.getRequestDispatcher("/b");
//        requestDispatcher.forward(req,resp);


    }
}
